<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
			$(function() {
				new NumPagination($("form"));

				$(".confirm").confirmDialog(function(data) {
					helper.showMsg(data, {
						okHandler : function() {
							location.reload();
						}
					});
				});
			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<s:if test='hasAuthorized("ielts.work.system")'>
			<ul class="breadcrumb">
				<li><a href="createUser">创建新用户</a><span class="divider">/</span></li>
				<li class="active">用户列表</li>
			</ul>
		</s:if>
		<form class="form-horizontal">
			<div class="control-group">
				<label class="control-label"> 名称 </label>
				<div class="controls">
					<input type="text" name="name" value="${param.name }" />
					<button type="submit" class="btn btn-primary">
						<i class="icon-search icon-white"></i> 查询
					</button>
				</div>
			</div>
		</form>
		<div>每页${users.size}项，共 ${users.totalElements} 项，当前${users.number+1}/ ${users.totalPages}页</div>
		<table class="table">
			<thead>
				<tr>
					<th>工号</th>
					<th>校区</th>
					<th>登录名</th>
					<th>名称</th>
					<th>说明</th>
					<th>所属角色</th>
					<th>创建时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="#users" var="user">
					<tr>
						<td>${user.no}</td>
						<td>${user.campus}</td>
						<td>${user.loginName}</td>
						<td><s:url action="viewUser" namespace="/security/user" id="viewUser">
								<s:param name="id" value="id"></s:param>
							</s:url> <a href="${viewUser}" title="查看用户">${user.name}</a></td>
						<td>${user.title}</td>
						<td><s:iterator value="roles" var="role" status="status">
								<s:url id="listUserInRole" value="../userrole/listUserInRole">
									<s:param name="id" value="id"></s:param>
								</s:url>
								<s:if test="!#status.first">,</s:if>
								<a title="${role.id}" href="${listUserInRole}">${role.title}</a>
							</s:iterator></td>
						<td><s:date name="createTime" format="yyyy-MM-dd" /></td>
						<td><s:if test='hasAuthorized("ielts.work.system")'>
								<s:url id="resetPwd" value="doResetPwd">
									<s:param value="id" name="id"></s:param>
								</s:url>
								<a href="${resetPwd}" title="重置密码" class="confirm">
									<i class="icon-warning-sign"></i>
								</a>
								<s:url id="modifyUserUrl" value="modifyUser">
									<s:param value="id" name="id"></s:param>
								</s:url>
								<a href="${modifyUserUrl}" title="编辑">
									<i class="icon-pencil"></i>
								</a>
								<s:url id="removeUserUrl" value="doRemoveUser">
									<s:param value="id" name="id"></s:param>
								</s:url>
								<a href="${removeUserUrl}" title="删除该用户" class="confirm">
									<i class="icon-remove"></i>
								</a>
							</s:if></td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
		<jsp:include page="/components/pagination/paginations.jsp"></jsp:include>
	</tiles:putAttribute>
</tiles:insertDefinition>